function split(str) {
  if (str!=undefined && str!=null) {
    return str.split(",");
  } else {
    return [];
  }
}
module.exports = {

  /**
   * 类别格式化
   */
   Category : function(data) {
    //console.log("Data befor format: ", data);
    const c = {
      id: data._id,
      color: data.color,
      name: data.name
    };

    return c;
  },
  /**
   * 图片格式化
   */
   Image : function(data) {
    //console.log("Data befor format: ", data);
    let c = {
      favorited : data.favorited || false,
      isLock : data.is_lock || true,
      name : data.name || "",
      figure : data.figure || "",
      isNew : data.is_new || false,
      price : data.price || 0,
      isHot : data.is_hot || false,
      scenesImg : data.scenes_img || "",
      id : data._id || "",
      pos : data.pos || 0,
      animationName : data.animationName || 0,
      colorImageList : split(data.colorImageList),
      steps : split(data.steps),
      dashImg : data.dashImg || "",
      favoriteCount : data.favorite_count || 0
    };

    return c;
  },
  /**
   * Banner格式化
   */
   Banner : function(data) {
    //console.log("Data befor format: ", data);
    const c = {
      isLock: data.isLock,
      name: data.name,
      figure: data.figure,
      color: data.color,
      price: data.price,
      imageId: data.imageId,
      deepLink: data.deepLink,
      id : data._id
    };

    return c;
  }
}
